package com.zjy.software.day16;

import com.zjy.software.utils.P;

import java.io.*;

public class PrintWriterDemo {
    public static void main(String[] args) throws IOException {
//        testPrinter();
//        testSystemin();
        PrintStream printStream = new PrintStream(new FileOutputStream("print.txt"));
        System.setOut(printStream);
        System.out.println("hello world");
        System.out.println("我是处理流对原来的out进行重定向的输出流");

    }

    private static void testSystemin() throws IOException {
        InputStream in=System.in;
        while (true) {
             int read = in.read();
             System.out.print(  read);
         }
    }

    private static void testPrinter() throws IOException {
        FileWriter fileWriter = new FileWriter("buffer1.txt");
        PrintWriter printWriter=new PrintWriter(fileWriter);
        printWriter.println(123);
        printWriter.println("hello world");
        printWriter.println(true);
        printWriter.println(1.0);
        printWriter.close();
        System.err.println("hello world");
    }
}
